home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1996 February
/
EnigmA AMIGA RUN 04 (1996)(G.R. Edizioni)(IT)[!][issue 1996-02][Skylink CD III].iso
/
earcd
/
comm2
/
termsorc.lha
/
Extras
/
Source
/
gtlayout-source.lha
/
LT_LabelWidth.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-09-24
|
1KB
|
81 lines
/* GadTools layout toolkit
**
** Copyright © 1993-1995 by Olaf `Olsen' Barthel
** Freely distributable.
*/
#include "gtlayout_global.h"
LONG LIBENT
LT_LabelWidth(REG(a0) LayoutHandle *handle,REG(a1) STRPTR label)
{
if(handle)
{
struct RastPort *rp = &handle -> RPort;
LONG start;
LONG len;
LONG cnt;
LONG width,maxWidth;
LONG underscore;
start = 0;
maxWidth = 0;
underscore = 0;
cnt = 0;
len = 0;
while(label[len])
{
if(label[len] == '_')
{
if(!underscore)
underscore = TextLength(rp,"_",1);
cnt += underscore;
}
if(label[len] == '\n')
{
if(len > start)
width = TextLength(rp,&label[start],len - start) - cnt;
else
width = 0;
cnt = 0;
start = len + 1;
if(width > maxWidth)
maxWidth = width;
}
len++;
}
if(len > start)
width = TextLength(rp,&label[start],len - start) - cnt;
else
width = 0;
if(width > maxWidth)
maxWidth = width;
return(maxWidth);
}
else
return(0);
}
/*****************************************************************************/
LONG LIBENT
LT_LabelChars(REG(a0) LayoutHandle *handle,REG(a1) STRPTR label)
{
if(handle)
return((LT_LabelWidth(handle,label) + handle -> GlyphWidth - 1) / handle -> GlyphWidth);
else
return(0);
}